package com.whli.autumn.mall.wms.domain.dto.convert;

import com.whli.autumn.mall.wms.domain.dto.StockActionDTO;
import com.whli.autumn.mall.wms.domain.dto.stock.StockQueryDTO;
import com.whli.autumn.mall.wms.domain.dto.stockdtl.StockDtlQueryDTO;
import com.whli.autumn.mall.wms.domain.entity.Stock;
import com.whli.autumn.mall.wms.domain.entity.StockDtl;
import com.whli.autumn.mall.wms.domain.entity.StockLog;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author whli
 * @version 1.0.0
 * @description
 * @since 2023/6/22 10:22
 */
@Mapper
public interface StockActionConvert {

    StockActionConvert INSTANCE = Mappers.getMapper(StockActionConvert.class);

    @Mappings({
            @Mapping(source = "toWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "toWarehouseInfoCode", target = "warehouseInfoCode"),
            @Mapping(source = "toWarehouseInfoName", target = "warehouseInfoName"),
            @Mapping(source = "toWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "toWarehouseAreaCode", target = "warehouseAreaCode"),
            @Mapping(source = "toWarehouseAreaName", target = "warehouseAreaName"),
            @Mapping(source = "toWarehouseLocationId", target = "warehouseLocationId"),
            @Mapping(source = "toWarehouseLocationCode", target = "warehouseLocationCode"),
            @Mapping(source = "toWarehouseLocationName", target = "warehouseLocationName"),
            @Mapping(source = "toWarehouseCategory", target = "warehouseCategory"),
            @Mapping(source = "toWarehouseProperty", target = "warehouseProperty")
    })
    Stock inToDomain(StockActionDTO dto);

    @Mappings({
            @Mapping(source = "fromWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "fromWarehouseInfoCode", target = "warehouseInfoCode"),
            @Mapping(source = "fromWarehouseInfoName", target = "warehouseInfoName"),
            @Mapping(source = "fromWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "fromWarehouseAreaCode", target = "warehouseAreaCode"),
            @Mapping(source = "fromWarehouseAreaName", target = "warehouseAreaName"),
            @Mapping(source = "fromWarehouseLocationId", target = "warehouseLocationId"),
            @Mapping(source = "fromWarehouseLocationCode", target = "warehouseLocationCode"),
            @Mapping(source = "fromWarehouseLocationName", target = "warehouseLocationName"),
            @Mapping(source = "fromWarehouseCategory", target = "warehouseCategory"),
            @Mapping(source = "fromWarehouseProperty", target = "warehouseProperty")
    })
    Stock outToDomain(StockActionDTO dto);

    @Mappings({
            @Mapping(source = "toWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "toWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "toWarehouseLocationId", target = "warehouseLocationId"),
    })
    StockQueryDTO inToQuery(StockActionDTO dto);

    @Mappings({
            @Mapping(source = "fromWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "fromWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "fromWarehouseLocationId", target = "warehouseLocationId"),
    })
    StockQueryDTO outToQuery(StockActionDTO dto);


    StockDtl actionToDtlDomain(StockActionDTO dto);

    @Mappings({
            @Mapping(source = "toWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "toWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "toWarehouseLocationId", target = "warehouseLocationId"),
    })
    StockDtlQueryDTO inToDtlQuery(StockActionDTO dto);

    @Mappings({
            @Mapping(source = "fromWarehouseInfoId", target = "warehouseInfoId"),
            @Mapping(source = "fromWarehouseAreaId", target = "warehouseAreaId"),
            @Mapping(source = "fromWarehouseLocationId", target = "warehouseLocationId"),
    })
    StockDtlQueryDTO outToDtlQuery(StockActionDTO dto);


    StockLog actionToLogDomain(StockActionDTO dto);

}
